function checkport {
        if nc -zv -w30 $1 $2 <<< '' &> /dev/null
        then
                echo "[+] Port $1/$2 is open"
                status=$(/bin/pidof keepalived | wc -l)
                if [ "${status}" = "0" ]; then
                    systemctl start keepalived
                fi
        else
                echo "[-] Port $1/$2 is closed"
                systemctl stop keepalived
        fi
}
checkport '127.0.0.1' 80